PROGRAM calcAvg;

  PROCEDURE CalculateAverage;
    VAR n, sum, amount, value: INTEGER;
  BEGIN 
    n := 0;
    sum := 0;
    WriteLn('calulate average:');
    WriteLn('amount of values >');
    ReadLn(amount);
    WriteLn('');
    WHILE amount > 0 DO BEGIN 
      ReadLn(value);
      n := n + 1;
      sum := sum + value;
      amount := amount - 1;
    END;    (* while*)
    IF n > 0 THEN BEGIN 
      WriteLn(sum / n);
    END ELSE BEGIN       (* n = 0*)
      WriteLn('no average');
    END;
  END;

BEGIN 
  (* todo: 'test' *);
  CalculateAverage();
  ReadLn();
END.